<template>
  <view class="container screen-width">
    <view class="content">
      <view class="name">{{ activityInfo.title }}</view>
      <!-- <view class="content-info" v-html="activityInfo.synopsis"></view> -->
      <view class="content-info">
        <text>{{ activityInfo.synopsis }}</text>
      </view>
      <view class="time">活动时间：{{ activityInfo.beginDate }}到{{ activityInfo.endDate }}</view>
    </view>
  </view>
</template>
<script>
import {getTenantActivityInfo} from '@/util/api/activity.js'
import { isWeixin, wxShareConfig } from "util/wx.js";
export default {
  data() {
    return {
      id: '',
      activityInfo: {},
    }
  },  
  onLoad(e) {
    this.id = e.id
    this.getDetail()
  },
  methods: {
    getDetail() {
      getTenantActivityInfo({id: this.id}).then(res=>{        
        if(res.code === 200) { 
          this.activityInfo = res.result
          if (isWeixin()) {
            this.initShareConfig()
          }
        }else{
          uni.showToast({
            title: res.message,
            duration: 2000,
            icon: "none"
          });
        }
      })
    },
    initShareConfig() {
      let windowurl = window.location.href.split("#")[0];
      let params = window.location.origin
      let url = params + '/pages/activity/Index?type=1&id=' + this.id
      uni.request({
        url: "https://oldm.51bmj.cn/WeiXin/GetClientSign", //仅为示例，并非真实接口地址。
        data: {
          rawUrl: windowurl
        },
        dataType: "json",
        header: {
          "X-Requested-With": "XMLHttpRequest"
        },
        method: "GET",
        success: res => {
          if (res.statusCode == 200) { 
            let { data } = res;
            let shareInfo = {
              title: this.activityInfo.title,
              desc: "政策尽知 红利尽享",
              link: url
            };
            wxShareConfig(this.$wx, data, shareInfo);
          }
        }
      });
    }
  }
}
</script>
<style lang="less" scoped>
.container{
  width: 100%;
  padding: 30rpx;
  box-sizing: border-box;
  .name {
    margin-bottom: 20rpx;
    font-size: 20px;
    color: #1678ff;
    font-weight: 700;
    text-align: center;
  }
  .content {
    border-radius: 10rpx;
    user-select: text;
    box-sizing: border-box;
    overflow: scroll;
    .content-info {
      user-select: text;
      font-size: 26rpx;
      line-height: 42rpx;
      text-indent: 48rpx;
    }
    .time{
      font-size: 24rpx;
      font-weight: bold;
      margin-top: 20rpx;
    }
  }
}
</style>
